package com.daiqee.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.daiqee.controller.support.CommonsController;
import com.daiqee.enums.RequestType;
import com.daiqee.pojo.SupplierArchives;
import com.daiqee.service.impl.SuppllierArchivesService;

/**
 * 供应商档案
 * 
 * <br/>
 * @since JDK 1.8
 * @version  V2.1
 * @author RichardTang 
 * @date: 2018年5月7日 下午5:56:29
 * @package com.daiqee.handler
 * @copyright:Copyright (c) 2018, 1245811923@qq.com All Rights Reserved.
 */
@Controller
@RequestMapping("procurement/supplier-archives")
public class SupplierArchivesController extends CommonsController<SupplierArchives>{
	
	@Autowired
	private SuppllierArchivesService supplierArchivesService;
	
	/**
	 * 根据id号 查询供应商 不进行数据格式化处理
	 * 
	 * @param supId 
	 * 			供应商id
	 * 
	 * @return restful风格 返回指定的供应商
	 */
	@RequestMapping(value="/supId={supId}",method=RequestMethod.GET)
	public Object queryById(@PathVariable("supId") Integer supId){
		SupplierArchives supplier = supplierArchivesService.selectById(supId);
		return restfulResponse.response(supplier,RequestType.GET);
	}
	
/*	@Override
	public Object warpperQueryMethod(SupplierArchives e, String dateScope, EntityWrapper<SupplierArchives> ew,
			Page<SupplierArchives> page) {
		//查询所有的供应商档案记录
		List<SupplierArchives> supplierArchives = supplierArchivesService.selectList(ew);
		
		//查询供应商分类
		List<SupplierClassification> supplierClassifications = supplierClassificationService.selectList(null);
		
		//查询所有的供应商级别分类
		List<SupplierLv> supplierLv = supplierLvService.selectList(null);
		
		//循环遍历出供应商记录
		for (SupplierArchives itemSupplierArchives : supplierArchives) {
			
			 * 根据查询到的供应商档案记录中的分类
			 * 获取 档案记录中的指定的对象
			 
			itemSupplierArchives.setSupArchiCustomerClass(
					supplierClassifications.get(Integer.parseInt(itemSupplierArchives.getSupArchiCustomerClass())-1)
					.getSupClassName());
			
			itemSupplierArchives.setSupArchiCustomerLv(
					supplierLv.get(Integer.parseInt(itemSupplierArchives.getSupArchiCustomerLv())-1).getSupLvName());
		}
		return supplierArchives;
	}*/
	
	/**	 
	 * 根据条件来查询供应商
	 * 
	 * @param sLv
	 * 			供应商等级
	 * 
	 * @param sClass
	 * 			供应商分类
	 * 
	 * @return 符合条件的供应商数据
	 */
	@RequestMapping(value="/{s-lv}-{s-class}",method=RequestMethod.GET)
	public Object  queryByCondition(@PathVariable("s-lv") String sLv,@PathVariable("s-class") String sClass){
		List<SupplierArchives> supplierArchivesList = 
		    supplierArchivesService.querySupplierArchivesByLvAndClass(sLv, sClass);
		return restfulResponse.response(supplierArchivesList,RequestType.GET);
	}
	
}
